#include <iostream>

#include "linear_equation.h"
#include "coefficient.h"

using namespace std;

/** @param number_of_coeficients the number of coefficients for the equation.
 */
LinearEquation::LinearEquation(int number_of_coeficients) {
  coefficients_ = vector<Coefficient> (number_of_coeficients, 
                                       Coefficient::ZeroInstance());
}

/** @param index the index of the variable to be replaced.
 *  @param coef the new Coefficient to put in the equation.
 */
void LinearEquation::SetIthCoefficient(int index, Coefficient coef) {
  coefficients_[index] = coef;
}

void LinearEquation::PrintEquationToStdout() {
  for (int cols = 0; cols < (int) coefficients_.size(); ++cols) {
    coefficients_[cols].PrintCoefficientToStdout();
    cout << " ";
  }
  cout << endl;
}

/** @param index The index of the required Coefficient in the equation. */
Coefficient LinearEquation::GetIthCoefficient(const int index) {
  if (index < 0 or index > (int)coefficients_.size())
    return Coefficient::ZeroInstance();
  return coefficients_[index];
}
